//
//  LBTool.m
//  Holyiot-DFU
//
//  Created by bill on 2021/6/18.
//

#import "LBHud.h"
@interface LBHud()
@property(nonatomic,strong)UILabel *textLab;

@end
@implementation LBHud

+(void)showText:(NSString*)text
{
    UILabel *lab = [[UILabel alloc]init];
    lab.font = [UIFont systemFontOfSize:16];
    lab.textColor = [UIColor whiteColor];
    lab.backgroundColor = [UIColor colorWithWhite:0.2 alpha:0.95];
    lab.layer.cornerRadius = 10;
    lab.layer.masksToBounds = YES;
    lab.textAlignment = NSTextAlignmentCenter;
    lab.numberOfLines = 0;
    lab.text = text;
    CGSize size = [lab sizeThatFits:CGSizeMake(kScreenWidth-60, CGFLOAT_MAX)];
    CGFloat labWidth = size.width + 20;
    CGFloat labHeight = size.height +20;
    lab.frame = CGRectMake((kScreenWidth - labWidth)/2, -labHeight, labWidth, labHeight);
    
    [[UIApplication sharedApplication].keyWindow addSubview:lab];
    [UIView animateWithDuration:0.5 delay:0.0 usingSpringWithDamping:0.5 initialSpringVelocity:0.5 options:UIViewAnimationOptionCurveEaseOut animations:^{
        NSLog(@"----->%f",[UIView getSafeInset_top]);
        lab.y = [UIView getSafeInset_top];
        } completion:^(BOOL finished) {
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [lab removeFromSuperview];
            });
        }];
}

@end
